<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/12
 * Time: 17:49
 */

namespace app\controllers;


use app\services\CookieServerService;
use yii\base\Exception;
use yii\web\Controller;

class TestController extends Controller
{
    public function actionIndex(){
        $gid = '41244724232';
        $aid = '2942e5387b2f4b2ca9cadd43208a2614';
        $sid = '2155643114';
        $app_name = 'test';
        //获取券信息测试
        $cookieServerCommon = new CookieServerService();
        try{
            $cookieServerCommon->setAppName($app_name);
            $cookieServerCommon->init($aid,$sid,$gid);
        }catch (Exception $e){
            $cookieServerCommon->setAppName($app_name);
            $cookieServerCommon->setApiVersion('1.0');
            try{
                $cookieServerCommon->init($aid,$sid,$gid);
            }catch (Exception $e3){
                try{
                    $tmp_data = CookieServerService::unionInfo($sid,$aid);
                    $cookieServerCommon->setApiVersion('2.0');
                    if(!empty($tmp_data)){
                        $cookieServerCommon->setData($tmp_data);
                    }
                }catch (Exception $e4){
                    return false;
                }
            }
        }

        $coupon['couponPrice'] = $cookieServerCommon->quan_price();
        $coupon['couponEndTime'] = $cookieServerCommon->endTime();
        $coupon['couponStartTime'] = $cookieServerCommon->startTime();
        $coupon['couponTiaoJian'] = $cookieServerCommon->quan_tiaojian();
        $coupon['couponOver'] = 0;
        $coupon['couponNum'] = 0;

        var_dump($coupon);
    }
}